﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace UrlParse
{
    class UrlParse
    {
        static void Main(string[] args)
        {

            string text = @"https://www.youtube.com/watch?v=P2yDhGJ-k78&feature=autoplay&list=PL98BB53ECCDEED45D&index=14&playnext=7&shuffle=429919";
            text += " Some text here ";
            text += @"http://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex.aspx ";
            text += @"http://www.google.com";
            text += " Some text here ";
            text += @"codeplex.com/";
            string pattern = @"(?<protocol>http[s]*)?(://)?(?<server>(([a-zA-Z_\-]+\.)+([a-zA-Z]{2,4})))(?<resources>\S*)?";

            MatchCollection result = Regex.Matches(text, pattern);
            foreach (Match item in result)
            {
                Console.WriteLine("Protocol: {0}", item.Groups["protocol"]);
                Console.WriteLine("Server: " + item.Groups["server"]);
                Console.WriteLine("Resources: " + item.Groups["resources"]);
                Console.WriteLine();
            }
        }
    }
}